<?php echo $this->render('grid_header.phtml') ?>

<table class="data-grid">
    <thead>
        <tr>
            <th style="width:35px" class="br">
    <div class="sort-column">
        <span class="sort-label fl">ID</span>
        <div class="sort fr">
            <span class="asc fieldNameid" ></span>
            <span class="desc fieldNameid"></span>
        </div>
        <div class="cls"></div>
    </div>
</th>
<th class="br">
<div class="sort-column">
    <span class="sort-label fl">Tytuł</span>
    <div class="sort fr">
        <span class="asc fieldNametitle" ></span>
        <span class="desc fieldNametitle"></span>
    </div>
    <div class="cls"></div>
</div>
</th>
<th class="br">
<div class="sort-column">
    <span class="sort-label fl">Rodzic</span>
    <div class="sort fr">
        <span class="asc fieldNameparent" ></span>
        <span class="desc fieldNameparent"></span>
    </div>
    <div class="cls"></div>
</div>
</th>
<th class="br">
<div class="sort-column">
    <span class="sort-label fl">Kolejność</span>
    <div class="sort fr">
        <span class="asc fieldNameposition" ></span>
        <span class="desc fieldNameposition"></span>
    </div>
    <div class="cls"></div>
</div>
</th>
<th>
    <span class="sort-column">Akcja</span><br>
    <span class="hidden-data">{"filterUrl":"/admin/index/categories"}</span>
    <a class="ajaxFilter" href="javascript:void(0);">Filtruj</a>
    <a class="ajaxFilterClear" href="javascript:void(0);">Wyczyść</a>    
</th>
</tr>
<tr>
    <td class="br">
        <div class="ui-filter">
            <input type="text" name="filterid" class="filterField" />
            <span class="hidden-data ui-filter-value">{"value":"<?php echo $this->wparams['id'] ?>"}</span>
        </div>
    </td>
    <td class="br">
        <div class="ui-filter">
            <input type="text" name="filtertitle" class="filterField" />
            <span class="hidden-data ui-filter-value">{"value":"<?php echo $this->wparams['title'] ?>"}</span>
        </div>
    </td>
    <td class="br">
        <div class="ui-filter">
            <input type="text" name="filterparent" class="filterField" />
            <span class="hidden-data ui-filter-value">{"value":"<?php echo $this->wparams['parentId'] ?>"}</span>
        </div>
    </td>
    <td class="br">
        <div class="ui-filter">
            <input type="text" name="filterposition" class="filterField" />
            <span class="hidden-data ui-filter-value">{"value":"<?php echo $this->wparams['position'] ?>"}</span>
        </div>
    </td>
    <td>

    </td>
</tr>
</thead>
<tbody>
    <?php if (count($this->paginator)): ?>
        <?php foreach ($this->paginator as $idx => $item): ?>
            <tr class="item-<?php echo $idx ?>">
                <td class="br"><?php echo $item['id'] ?></td>
                <td class="br">
                    <a class="default" href="<?php echo $this->url(array('module' => 'admin', 'action' => 'categoryedit', 'id' => $item['id']), null, true) ?>">
                        <?php echo $item['title'] ?>
                    </a>
                </td>
                <td class="br">
                    <span><?php echo $item['parentId'] ?></span>
                    <a href="<?php
                echo $this->url(array(
                    'module' => 'admin', 'controller' => 'index', 'action' => 'categories',
                    'filterparentId' => $item['id']
                        ), 'default', false)
                        ?>">
                        Pokaż podrzędne(<?php echo $item['count']?>)
                    </a>
                </td>
                <td class="br">
                    <span><?php echo $item['position'] ?></span>
                    <div>
                        <a rel="<?php echo $item['id'] ?>up" class="ajax-post" href="<?php echo $this->url(array('module' => 'admin', 'action' => 'setmodel', 'id' => $item['id'], 'table' => 'categories'), null, true) ?>">Up</a>
                    <div id="ajx-pdata-<?php echo $item['id'] ?>up" class="ajax-post-data"><?php echo Zend_Json::encode(array('position' => $item['position']+1)) ?></div>
                    <a rel="<?php echo $item['id'] ?>down" class="ajax-post" href="<?php echo $this->url(array('module' => 'admin', 'action' => 'setmodel', 'id' => $item['id'], 'table' => 'categories'), null, true) ?>">Down</a>
                    <div id="ajx-pdata-<?php echo $item['id'] ?>down" class="ajax-post-data"><?php echo Zend_Json::encode(array('position' => $item['position']-1)) ?></div>
                    </div>
                </td>
                <td >
                    <a rel="<?php echo $item['id'] ?>d" class="ajax-post" href="<?php echo $this->url(array('module' => 'admin', 'action' => 'setmodel', 'id' => $item['id'], 'table' => 'categories'), null, true) ?>">Usuń</a>
                    <div id="ajx-pdata-<?php echo $item['id'] ?>d" class="ajax-post-data"><?php echo Zend_Json::encode(array('delete' => Application_Model_Content::S_TRASH)) ?></div>
                    <a href="<?php echo $this->url(array('module' => 'admin', 'action' => 'categoryedit', 'id' => $item['id']), null, true) ?>">Edytuj</a>
                </td>
            </tr>
    <?php endforeach; ?>
<?php endif; ?>
</tbody>
<tfoot>
    <tr>
        <td colspan="7">
            <?php
            echo $this->paginationControl($this->paginator, 'Sliding', 'pg_nav01.phtml');
            ?>
        </td>
    </tr>
</tfoot>
</table>
